<?php
/**
 * ImportCSV Module
 *
 * @author Artem Demchenkov <lunoxot@mail.ru>
 * @version 0.0.3
 *
 * module form
 */

$this->breadcrumbs=array(
	Yii::t('importcsvModule.importcsv', 'Import')." CSV",
);

$this->pageTitle = Yii::t('importcsvModule.importcsv', 'Import');
?>

<div class="widget blue">
    <div class="widget-title">
        <h4><i class="icon-upload-alt"></i> <?php echo Yii::t('importcsvModule.importcsv', 'Import'); ?> </h4>
        <span class="tools">
            <a href="javascript:;" class="icon-chevron-down"></a>
            <!--a href="javascript:;" class="icon-remove"></a-->
        </span>
     </div>
    <div class="widget-body">
        <div class="alert alert-info medium-alert">
            <strong><?php echo Yii::t('importcsvModule.importcsv', 'File'); ?> :</strong> <span id="importCsvForFile">&nbsp;</span><br/>
            <strong><?php echo Yii::t('importcsvModule.importcsv', 'Fields Delimiter'); ?> :</strong> <span id="importCsvForDelimiter">&nbsp;</span><br/>
            <strong><?php echo Yii::t('importcsvModule.importcsv', 'Text Delimiter'); ?> :</strong> <span id="importCsvForTextDelimiter">&nbsp;</span><br/>
            <strong><?php echo Yii::t('importcsvModule.importcsv', 'Table'); ?> :</strong> <span id="importCsvForTable">&nbsp;</span>
        </div>
        
        <?php echo CHtml::beginForm('','post',array('enctype'=>'multipart/form-data', 'class' => 'form-horizontal')); ?>
        <?php echo CHtml::hiddenField("fileName", ""); ?>
        <?php echo CHtml::hiddenField("thirdStep", "0"); ?>

        <div id="importCsvFirstStep">
            <div id="importCsvFirstStepResult">&nbsp;</div>
            <div>
            <?php $this->widget('bootstrap.widgets.TbButton', array(
                'label'=> Yii::t('importcsvModule.importcsv', 'Select CSV File'),
                'htmlOptions' => array("id"=>"importStep1")
            )); ?>
            </div>
        </div>

        <div id="importCsvSecondStep">
            <div id="importCsvSecondStepResult">&nbsp;</div>
            <?php echo CHtml::hiddenField("delimiter", $delimiter); ?>
            <?php echo CHtml::hiddenField("textDelimiter", $textDelimiter); ?>
            
            <div class="span12">
                <div class="control-group">
                    <label class="control-label required" for="table"><?php echo Yii::t('importcsvModule.importcsv', 'Table'); ?> <span class="required">*</span></label>
                    <div class="controls">
                        <?php echo CHtml::dropDownList('table', '', $tablesArray);?>
                    </div>                        
                </div>
            </div>

            <div>
            <?php $this->widget('bootstrap.widgets.TbButton', array(
                            'label'=> Yii::t('importcsvModule.importcsv', 'Next'),
                            'icon' => 'icon-arrow-right',
                            'buttonType' => 'ajaxSubmit',
                            'ajaxOptions' => array(
                                'update' => '#importCsvSecondStepResult',
                            )
                    )); ?>
            </div>
        </div>
    <?php echo CHtml::endForm(); ?>

        <div id="importCsvThirdStep">
            <?php echo CHtml::beginForm('','post'); ?>
                <?php echo CHtml::hiddenField("thirdStep", "1"); ?>
                <?php echo CHtml::hiddenField("thirdDelimiter", ""); ?>
                <?php echo CHtml::hiddenField("thirdTextDelimiter", ""); ?>
                <?php echo CHtml::hiddenField("thirdTable", ""); ?>
                <?php echo CHtml::hiddenField("thirdFile", ""); ?>
                <div id="importCsvThirdStepResult">
                    &nbsp;
                </div>
                <div id="importCsvThirdStepColumnsAndForm">
                    <div id="importCsvThirdStepColumns">&nbsp;</div>
                    <div class="form-actions">
                    <?php $this->widget('bootstrap.widgets.TbButton', array(
                            'label'=> Yii::t('importcsvModule.importcsv', 'Import'),
                            'buttonType' => 'ajaxSubmit',
                            'loadingText' => 'Cargando',
                            'ajaxOptions' => array(
                                'beforeSend' => 'function(){
                                    $(".btn").html("Cargando...");
                                    $(".btn").attr("disabled", true);
                                    $(".btn").addClass("disabled");

                                }',
                                'update' => '#importCsvThirdStepResult',
    //                            'complete' => 'js:function(){hideFieldLoading($(#importCsvThirdStepResult));}',
                            ),
                    )); ?>
                </div>
                </div>
            <?php echo CHtml::endForm(); ?>
        </div>
        <br/>
        <div class="form-options">
            <span id="importCsvBread1">&laquo; <?php echo CHtml::link(Yii::t('importcsvModule.importcsv', 'Start over'), array("/importcsv"));?></span>
        </div>
    </div>
</div>

